package com.itsc.dao;

import java.util.List;

import org.hibernate.Query;

import com.itsc.entities.Dictionary;
import com.itsc.util.page.Page;

public class DictionaryDao extends BaseDao<Dictionary>{
	@SuppressWarnings("unchecked")
	public List<Dictionary> search(String searchname, Page page) {
		searchname = searchname == null ? "" : searchname;
		String hql = "from Dictionary where dic_name like ?";
		Query query = getSession().createQuery(hql);
		query.setString(0, "%" + searchname + "%");
		if (page != null) {
			query.setFirstResult(page.getBeginIndex());
			query.setMaxResults(page.getPageSize());
		}
		return query.list();
	}
}
